import { Component, OnInit } from '@angular/core';

declare var form: any;

@Component({
  templateUrl: './notice.info.component.html'
})
export class NoticeInfoComponent implements OnInit {

  fs: any = null;
  logfs: any = null;
  issend: any;
  visible = false;

  constructor() {
    this.fs = new form.FormSimpleService('notice', {
      orderObject: { accepttime: 1 },
      keyField: 'id',
      randomFields: ['id']
    });
    this.fs.loadData(true);

    this.logfs = new form.FormSimpleService('noticelog', {
      orderObject: { id: 0 },
      keyField: 'id',
      randomFields: ['id']
    });
  }

  ngOnInit() {
  }

  iniFsData() {
    if (this.issend === 'true') {
      this.fs.queryObject.issend = true;
    } else if (this.issend === 'false') {
      this.fs.queryObject.issend = false;
    } else {
      this.fs.queryObject.issend = 'nullItem';
    }
    this.fs.loadData(true);
  }

  resetFs() {
    this.issend = null;
    this.fs.resetQueryObject();
    this.iniFsData();
  }

  // 打开弹窗详细信息
  open(id): void {
    this.visible = true;
    this.logfs.defaultQueryObject = { 'infoid:=': id };
    this.logfs.loadData(true);
  }

  // 关闭弹窗
  close(): void {
    this.visible = false;
  }
}
